import React, { Component } from "react";
import Form from "./Form";
import List from "./List";

import { connect } from "react-redux";
import { loadAction } from "./store/actionCreator";

const mapDispatchToProps = (dispatch) => {
  return {
    load() {
      dispatch(loadAction());
    },
  };
};

class App extends Component {
  render() {
    return (
      <>
        <h3>redux-todolist-async</h3>
        <Form />
        <List />
      </>
    );
  }

  componentDidMount() {
    this.props.load();
  }

  // componentDidMount() {
  //   fetch("http://www.pudge.wang:3080/api/rated/list")
  //     .then((response) => response.json())
  //     .then(() => {
  //       console.log([
  //         {
  //           name: "zhangsan",
  //           id: 1,
  //         },
  //         {
  //           name: "lisi",
  //           id: 2,
  //         },
  //       ]);
  //     });
  // }
}

export default connect(null, mapDispatchToProps)(App);
